]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
popupMenu: Add focusActor property to define the default focus actor
authorMarco Trevisan (Treviño) <mail@3v1n0.net>
Fri, 13 Sep 2019 03:15:41 +0000 (05:15 +0200)
committerFlorian Müllner <florian.muellner@gmail.com>
Fri, 20 Sep 2019 15:53:42 +0000 (15:53 +0000)
The PopupMenuManager is supposed to grab and focus the menu actors, with
normal menus we always need to grab the actual menu but set the key focus to
the source actor so that it will be able to move the focus to the menu
child, if requested.

However there are menus such as the RenameFolderMenu that requires the
key-focus once prompted, so provide a focusActor property (defaulting to the
sourceActor) that can be set in order to define the actor to give the
keyboard focus to, when the menu is popped-up.

Fixes https://gitlab.gnome.org/GNOME/gnome-shell/issues/1604
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/720

js/ui/popupMenu.js

index ad9b3c77c3b37b74eed48190fb3b034a079700a7..49ed823b127ea78476571cb4cd21dd9eda3fc463 100644 (file)
@@ -428,6 +428,7 @@ var PopupMenuBase = class {
             throw new TypeError(`Cannot instantiate abstract class ${this.constructor.name}`);
 
         this.sourceActor = sourceActor;
+        this.focusActor = sourceActor;
         this._parent = null;
 
         if (styleClass !== undefined) {
@@ -1300,10 +1301,11 @@ var PopupMenuManager = class {
         if (open) {
             if (this.activeMenu)
                 this.activeMenu.close(BoxPointer.PopupAnimation.FADE);
-            this._grabHelper.grab({ actor: menu.actor, focus: menu.sourceActor,
-                                    onUngrab: isUser => {
-                                        this._closeMenu(isUser, menu);
-                                    } });
+            this._grabHelper.grab({
+                actor: menu.actor,
+                focus: menu.focusActor,
+                onUngrab: isUser => this._closeMenu(isUser, menu),
+            });
         } else {
             this._grabHelper.ungrab({ actor: menu.actor });
         }